//
//  ViewController.m
//  MenuDemo
//
//  Created by 卢浩 on 16/4/14.
//  Copyright © 2016年 卢浩. All rights reserved.
//

#import "ViewController.h"
#import "MenuViewController.h"

@interface ViewController ()<MenuCellClickDelegate>

/**
 *  左侧标题Lable
 */
@property (weak, nonatomic) IBOutlet UILabel *leftTitleLable;

/**
 *  右侧标题Lable
 */
@property (weak, nonatomic) IBOutlet UILabel *rightTitleLable;

@end

@implementation ViewController

//完成协议方法
- (void)didClickLeftMenuCellTitle:(NSString *)title{
    self.leftTitleLable.text = title;
}

- (void)didClickRightMenuCellTitle:(NSString *)title{
    self.rightTitleLable.text = title;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //设置协议代理
    [MenuViewController getMenuVC].clickMenuCellDelegate = self;

    //在导航添加菜单按钮
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"菜单"] style:(UIBarButtonItemStylePlain) target:self action:@selector(showOrHideLeftMenuAction)];
    //在导航添加用户按钮
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"头像"] style:(UIBarButtonItemStylePlain) target:self action:@selector(showOrHideRightMenuAction)];
}

/**
 *  展示或隐藏左侧抽屉
 */
- (void)showOrHideLeftMenuAction {
    //判断是否已展示
    if ([MenuViewController getMenuVC].isLeftShow) {
        [[MenuViewController getMenuVC] hideLeftVC];
    }else{
        [[MenuViewController getMenuVC] showLeftVC];
    }
}

/**
 *  展示或隐藏右侧抽屉
 */
- (void)showOrHideRightMenuAction {
    //判断是否已展示
    if ([MenuViewController getMenuVC].isRightShow) {
        [[MenuViewController getMenuVC] hideRightVC];
    }else{
        [[MenuViewController getMenuVC] showRightVC];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
